package tv.youxing.android.custom;

import android.os.CountDownTimer;
import android.widget.Button;

/**
 * Created by Administrator on 2017/6/15.
 * Button倒计时类
 */

public class CustomCountDownTimer  extends CountDownTimer {

    Button btn;


    public CustomCountDownTimer(long millisInFuture, long countDownInterval, Button btn_djs) {
        super(millisInFuture, countDownInterval);
        this.btn = btn_djs;
    }


    //过程
    @Override
    public void onTick(long l) {
        btn.setClickable(false);
        btn.setEnabled(false);
        btn.setText(l/1000+"s");

    }

    //结束
    @Override
    public void onFinish() {
        //重新给Button设置文字
        btn.setText("重新获取验证码");
        //设置可点击
        btn.setEnabled(true);
        btn.setClickable(true);
    }
}
